//
//  OriginalView.m
//  Weibo
//
//  Created by wpapple on 16/6/6.
//  Copyright © 2016年 wpapple. All rights reserved.
//

#import "OriginalView.h"

@interface OriginalView ()

@property (nonatomic,strong) IBOutlet UIImageView *iconImage;

@property (nonatomic,strong) IBOutlet UILabel *nameLabel;

@property (nonatomic,strong) IBOutlet UILabel *timeLable;

@property (nonatomic,strong) IBOutlet UILabel *sourceLable;

@property (nonatomic,strong) IBOutlet UIImageView *VIPimage;

@property (nonatomic,strong) IBOutlet UILabel *contentLable;

@property (nonatomic,strong) IBOutlet UIImageView *photoImage;

@property (nonatomic,strong) IBOutlet NSLayoutConstraint *photoHeight;

@end

@implementation OriginalView

-(void)setStatus:(IWStatus *)status
{
    _status = status;
    
    //头像
    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:_status.user.profile_image_url] placeholderImage:[UIImage imageNamed:@"avatar_default_big"]];
    
    //昵称
    self.nameLabel.text = _status.user.name;
    
    //会员图标
    if ([_status.user isVip]) {
        self.VIPimage.hidden = NO;
        
        NSString *imageName = [NSString stringWithFormat:@"common_icon_membership%d",_status.user.mbrank.intValue];
        
        self.VIPimage.image = [UIImage imageNamed:imageName];
        
        self.nameLabel.textColor = [UIColor blueColor];
    }else
    {
        self.VIPimage.hidden = YES;
        
        self.nameLabel.textColor = [UIColor orangeColor];
    }
    
    //时间
    self.timeLable.text = _status.created_at;
    
    //来源
    self.sourceLable.text = _status.source;
    
    //正文
    self.contentLable.text = _status.text;
    self.contentLable.numberOfLines = 0;
    
    //设置数据
    if (status.pic_urls.count > 0) {
        NSMutableDictionary *photo = status.pic_urls[0];
        
        NSURL *imageUrl = [NSURL URLWithString:photo[@"thumbnail_pic"]];
        
        //下载图片
        [self.photoImage sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"avatar_default_big"]];
    }else
    {
        self.photoHeight.constant = 0;
    }
    
}
@end
